<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>生产异常处置单</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
<div class="demoTable" style="padding:10px 0 0 15px">
    <div class="layui-inline">
        <input class="layui-input" name="keyword" id="keyword" autocomplete="off" placeholder="请输入编号">
    </div>
    <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<div class="layui-tab" id="tab" style="width: 90%;padding: 2em 0 0 5em;display: none;">
	<ul class="layui-tab-title">
		<li class="layui-this">工艺处理结果</li>
		<li>品质处理结果</li>
	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show" id="tab1"></div>
		<div class="layui-tab-item" id="tab2"></div>
	</div>
</div>
<div id="formDiv" hidden>
	<form class="layui-form" id="addform">
		<input type="hidden" id="adID" name="adID"><br>
		<input type="hidden" id="reserve5" name="reserve5"><br>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 80px;">编号</label>
				<div class="layui-input-inline">
					<input class="layui-input" type="text" id="adNum" name="adNum" style="width:300px;" lay-verify="adNum">
				</div><span style="color:red; font-size: 24px;float: right;margin: 10px -5em 0 0;">*</span>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 80px;">发生工序段</label>
				<div class="layui-input-inline" style="width: 300px;">
					<select class="layui-input" lay-search="" id="processPart" name="processPart" lay-verify="processPart">
						<option value=""></option>
						<c:forEach items="${pList }" var="p">
							<option value="${p.pname }">${p.pname }</option>
						</c:forEach>
					</select><span style="color:red; font-size: 24px;float: right;margin: -28px -1em 0 0;">*</span>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 80px;">时间</label>
				<div class="layui-input-inline">
					<input class="layui-input" type="text" id="adDate" name="adDate" style="width:300px;" lay-verify="adDate">
				</div><span style="color:red; font-size: 24px;float: right;margin: 10px -5em 0 0;">*</span>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 80px;">异常说明</label>
				<div class="layui-input-inline">
					<textarea lay-verify="description" class="layui-textarea" id="description" name="description" style="width:300px;"></textarea>
				</div><span style="color:red; font-size: 24px;float: right;margin: 40px -5em 0 0;">*</span>
			</div>
		</div>
		<button id="subBtn1" class="layui-btn layui-btn-blue" lay-submit lay-filter="addform" style="margin-left:140px">提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</form>
</div>
<div id="formDiv2" hidden>
	<form class="layui-form">
		<h1 align="center">工艺变更通知单</h1><br>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">编号</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="noticeNum" name="noticeNum" style="width:300px;">
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">日期</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="noticeDate" name="noticeDate" style="width:300px;">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">有效期</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="validityPeriod" name="validityPeriod" style="width:300px;">
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">适用工序</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="applicableProcess" name="applicableProcess" style="width:300px;">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">内容</label>
				<div class="layui-input-inline">
					<textarea class="layui-textarea" readonly id="content" name="content" style="width:300px;"></textarea>
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">拟定人</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="draftPerson" name="draftPerson" style="width:300px;">
				</div>
			</div>
		</div>
		<!-- <div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">会签</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="sign" name="sign" style="width:300px;">
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">批准</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="approve" name="approve" style="width:300px;">
				</div>
			</div>
		</div> -->
	</form>
</div>

<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" lay-event="add"><i class="layui-icon layui-icon-add-1">  新增</i></button>
	</div>
</script>
 
<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="approval">发起审批</a>
</script>
              
          
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
<jsp:include page="ScriptInc.jsp"></jsp:include> 
 
<script>
layui.use(['table','layer','upload','form'], function(){
	var laydate = layui.laydate;
	  
	//执行一个laydate实例
	laydate.render({
		elem: '#adDate' //指定元素
	});
	
	var table = layui.table;
	var layer = layui.layer,
    form = layui.form;
	
	var $ = layui.jquery, active = {
			reload:function () {
				var keyword = $("#keyword").val();
				console.log(keyword)
				table.reload('contenttable',{
					method:'get',
					where:{adNum: keyword}
					,page: {
						curr: 1 //重新从第 1 页开始
					}
				});
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/abnormalDisposal/listPageAbnormalDisposal.do'
	    ,toolbar: '#toolbarDemo'
	    ,title: '生产异常处置单数据表'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,cols: [[
	      {type: 'checkbox', fixed: 'left'}
	      ,{type: 'numbers', fixed: 'left', title:'序号', width:'5%'}
	      ,{field:'adNum', title:'编号', width:'10%'}
	      ,{field:'processPart', title:'发生的工序段', width:'10%'}
	      ,{field:'adDate', title:'日期', width:'10%', templet: function(d){
	          return timestampToDate(d.adDate.time);
	      }}
	      ,{field:'squadLeader', title:'当班班长', width:'10%'}
	      /* ,{field:'processer', title:'工艺段负责', width:'10%'} */
	      ,{field:'description', title:'异常说明'}
	      ,{field:'reserve1', title:'处理结果', templet: function(d){
	          if (d.reserve1 == '-1') {
	        	  return '已驳回';
			} else if(d.reserve1 == '-2'){
				return '待审批';
			}else {
				 if (d.reserve1 == '6') {
						return '处理完成';
					} else {
						return '处理中';
					}
			}
	      }}
	      ,{field:'manager', title:'基地经理处理结果', templet: function(d){
	          if (d.manager != '' && d.manager != null) {
	        	  if (d.reserve1 == '-1') {
	        		  return d.manager+'（已驳回）';
				} else {
					return d.manager+'（处理完成）';
				}
			} else {
				 return '';
			}
	      }}
	      ,{field:'isNormal', title:'是否恢复', templet: function(d){
	          if (d.isNormal == '0') {
					return '否';
				} else if (d.isNormal == '1') {
					return '是';
				} else {
					return '';
				}
		  }}
	      ,{field:'isDowntime', title:'是否停机', templet: function(d){
	          if (d.isDowntime == '0') {
					return '否';
				} else if (d.isDowntime == '1') {
					return '是';
				} else {
					return '';
				}
		  }}
	      ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:250}
	    ]]
	    ,page: true
	});
	
	//监听行单击事件
	table.on('row(test)', function(obj){
		var rowData = obj.data;
		var rowReserve1="";
		var manager="";
		var isNormal="";
		var isDowntime="";
		if (rowData.reserve1 == '-1') {
      	  rowReserve1 = '已驳回';
		} else if(rowData.reserve1 == '-2'){
			rowReserve1 = '待审批';
		}else {
			 if (rowData.reserve1 == '6') {
					rowReserve1 = '处理完成';
				} else {
					rowReserve1 = '处理中';
				}
		}
		if (rowData.manager != '' && rowData.manager != null) {
      	  if (rowData.reserve1 == '-1') {
      			manager= rowData.manager+'（已驳回）';
			} else {
				manager = rowData.manager+'（处理完成）';
			}
		} else {
			manager= '';
		}
		 if (rowData.isNormal == '0') {
			 isNormal= '否';
			} else if (rowData.isNormal == '1') {
				isNormal= '是';
			} else {
				isNormal= '';
			}
		 if (rowData.isDowntime == '0') {
			 isDowntime= '否';
			} else if (rowData.isDowntime == '1') {
				isDowntime= '是';
			} else {
				isDowntime= '';
			}
		$.ajax({
	    	type:'post',
	    	url:'${pageContext.request.contextPath }/abnormalDisposalCraft/findAbnormalDisposalCraftByAdID.do',
	    	data:{"adID": obj.data.adID},
	    	success:function(data){
	    		$('#tab1').empty();
	    		var abnormalDisposalCraft = eval("("+data+")");
	    		if (abnormalDisposalCraft[0] == null) {
	    			$('#tab1').append('<div style="text-align: center;font-size: 25px;font-weight: 500;padding-top: 1em;">未处理</div>');
				} else {
					var isNormal = '';
					var reserve1 = '';
		    		if (abnormalDisposalCraft[0].reserve1 == '0') {
		    			reserve1 = '(已通过)';
		    		} else if(bnormalDisposalCraft[0].reserve1 != '-2'){
		    			reserve1 = '(已驳回)';
					}
		    		if (abnormalDisposalCraft[0].isNormal == '0') {
		    			isNormal = '未恢复正常';
		    			$('#tab1').append('<input class="layui-btn layui-btn-blue" type="button" onclick="doPrint1()" value="打印"/><!--startprint1-->'+
		    					'<table class="layui-table" style="width:90%"><tr>'+
		    						'<th>编号</th><th>发生的工序段</th><th>日期</th><th>当班班长</th><th>异常说明</th><th>处理结果</th><th>基地经理处理结果</th><th>是否恢复</th><th>是否停机</th>'+
		    					'</tr>'+
		    					'<tbody><tr><td>'+rowData.adNum+'</td><td>'+rowData.processPart+'</td><td>'+timestampToDate(rowData.adDate.time)+'</td><td>'+rowData.squadLeader+'</td><td>'+rowData.description+'</td><td>'+rowReserve1+'</td><td>'+manager+'</td><td>'+isNormal+'</td><td>'+isDowntime+'</td></tr></tbody>'+
		    					'</table>'+
		    					'<h1 style="text-align: center;">工艺处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
			    				'<tbody><tr height="100px;"><td style="width: 10%;">调整过程描述</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionDescription+'</td><td style="width: 10%;">调整结果说明</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionResult+'</td><td style="width: 10%;">'+isNormal+'</td></tr><tr><td colspan="5" '+
			    				'style="text-align: right;">负责人:'+abnormalDisposalCraft[0].craftMan+reserve1+'</tdth></tr></tbody></table><!--endprint1-->');
					} else {
						isNormal = '已恢复正常';
						$('#tab1').append('<input class="layui-btn layui-btn-blue" type="button" onclick="doPrint2()" value="打印"/><!--startprint2-->'+
								'<table class="layui-table" style="width:90%"><tr>'+
	    						'<th>编号</th><th>发生的工序段</th><th>日期</th><th>当班班长</th><th>异常说明</th><th>处理结果</th><th>基地经理处理结果</th><th>是否恢复</th><th>是否停机</th>'+
		    					'</tr>'+
		    					'<tbody><tr><td>'+rowData.adNum+'</td><td>'+rowData.processPart+'</td><td>'+timestampToDate(rowData.adDate.time)+'</td><td>'+rowData.squadLeader+'</td><td>'+rowData.description+'</td><td>'+rowReserve1+'</td><td>'+manager+'</td><td>'+isNormal+'</td><td>'+isDowntime+'</td></tr></tbody>'+
		    					'</table>'+
								'<h1 style="text-align: center;">工艺处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
			    				'<tbody><tr height="100px;"><td style="width: 10%;">调整过程描述</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionDescription+'</td><td style="width: 10%;">调整结果说明</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionResult+'</td><td style="width: 10%;">'+isNormal+'</td><td style="width: 10%;">'+
			    				'<a class="layui-btn layui-btn-sm" id="view"><i class="layui-icon layui-icon-search">变更通知单</i></a></td></tr>'+
			    				'<tr><td colspan="6" style="text-align: right;">负责人:'+abnormalDisposalCraft[0].craftMan+reserve1+'</td></tr></tbody></table><!--endprint2-->');
					}
		    		$('#view').on('click', function() {
						layer.open({
							type: 1 		//Page层类型
							,area: ['60%', '70%'] //宽  高
							,title: '工艺变更通知单'
							,shade: 0.6 	//遮罩透明度
							,shadeClose: true //点击遮罩关闭
							,maxmin: true //允许全屏最小化
							,anim: 1 		//0-6的动画形式，-1不开启
							,content: $('#formDiv2')
							,success: function () {
								$.ajax({
					    			type:'post',
					    			url:'${pageContext.request.contextPath }/changeNotice/findChangeNoticeByID.do',
					    			data:{"noticeID": abnormalDisposalCraft[0].noticeID},
					    			success:function(data){
					    				var changeNotice = eval("("+data+")");
					    	    		$('#noticeNum').val(changeNotice[0].noticeNum);
					    	    		$('#noticeDate').val(timestampToDate(changeNotice[0].noticeDate.time));
					    	    		$('#validityPeriod').val(changeNotice[0].validityPeriod);
					    	    		$('#applicableProcess').val(changeNotice[0].applicableProcess);
					    	    		$('#content').val(changeNotice[0].content);
					    	    		$('#draftPerson').val(changeNotice[0].draftPerson);
					    			}
					    		});
								form.render();
							}
							,end: function () {
								var formDiv = document.getElementById('formDiv2');
								formDiv.style.display = '';
							}
						});
					})
				}
	    	}
	    })
		$.ajax({
	    	type:'post',
	    	url:'${pageContext.request.contextPath }/abnormalDisposalQuality/findAbnormalDisposalQualityByAdID.do',
	    	data:{"adID": obj.data.adID},
	    	success:function(data){
	    		$('#tab2').empty();
	    		var abnormalDisposalQuality = eval("("+data+")");
	    		if (abnormalDisposalQuality[0] == null) {
	    			$('#tab2').append('<div style="text-align: center;font-size: 25px;font-weight: 500;padding-top: 1em;">未处理</div>');
				} else {
					if (obj.data.isNormal == 1) {
						if (abnormalDisposalQuality[0].reserve1 == '0') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
							$('#tab2').append('<input class="layui-btn layui-btn-blue" type="button" onclick="doPrint3()" value="打印"/><!--startprint3-->'+
									'<table class="layui-table" style="width:90%"><tr>'+
		    						'<th>编号</th><th>发生的工序段</th><th>日期</th><th>当班班长</th><th>异常说明</th><th>处理结果</th><th>基地经理处理结果</th><th>是否恢复</th><th>是否停机</th>'+
			    					'</tr>'+
			    					'<tbody><tr><td>'+rowData.adNum+'</td><td>'+rowData.processPart+'</td><td>'+timestampToDate(rowData.adDate.time)+'</td><td>'+rowData.squadLeader+'</td><td>'+rowData.description+'</td><td>'+rowReserve1+'</td><td>'+manager+'</td><td>'+isNormal+'</td><td>'+isDowntime+'</td></tr></tbody>'+
			    					'</table>'+
									'<h1 style="text-align: center;">品质处理结果</h1><table id="printTab1" class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr></tbody></table><!--endprint3-->');
						} else if (abnormalDisposalQuality[0].reserve1 == '1') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
							$('#tab2').append('<input class="layui-btn layui-btn-blue" type="button" onclick="doPrint4()" value="打印"/><!--startprint4-->'+
									'<table class="layui-table" style="width:90%"><tr>'+
		    						'<th>编号</th><th>发生的工序段</th><th>日期</th><th>当班班长</th><th>异常说明</th><th>处理结果</th><th>基地经理处理结果</th><th>是否恢复</th><th>是否停机</th>'+
			    					'</tr>'+
			    					'<tbody><tr><td>'+rowData.adNum+'</td><td>'+rowData.processPart+'</td><td>'+timestampToDate(rowData.adDate.time)+'</td><td>'+rowData.squadLeader+'</td><td>'+rowData.description+'</td><td>'+rowReserve1+'</td><td>'+manager+'</td><td>'+isNormal+'</td><td>'+isDowntime+'</td></tr></tbody>'+
			    					'</table>'+
									'<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr></tbody></table><!--endprint4-->');
						} else if(abnormalDisposalQuality[0].reserve1 != '-2'){
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
				    		var reserve5 = '';
				    		if (abnormalDisposalQuality[0].reserve5 == '0') {
				    			reserve5 = '(已通过)';
							} else {
								reserve5 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr><tr height="100px;"><td style="width: 20%;">制造部处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion3+'</td></tr><tr><td colspan="2" style="text-align: right;">制造部负责人:'+
				    				abnormalDisposalQuality[0].makePerson+reserve5+'</td></tr></tbody></table>');
						}
					} else {
						if (abnormalDisposalQuality[0].reserve1 == '0') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr></tbody></table>');
						} else if (abnormalDisposalQuality[0].reserve1 == '1') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr></tbody></table>');
						} else if(abnormalDisposalQuality[0].reserve1 != '-2'){
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
				    		var reserve5 = '';
				    		if (abnormalDisposalQuality[0].reserve5 == '0') {
				    			reserve5 = '(已通过)';
							} else {
								reserve5 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr><tr height="100px;"><td style="width: 20%;">制造部是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion3+'</td></tr><tr><td colspan="2" style="text-align: right;">制造部负责人:'+
				    				abnormalDisposalQuality[0].makePerson+reserve5+'</td></tr></tbody></table>');
						}
					}
				}
	    	}
	    })
	    var tab = document.getElementById('tab');
		tab.style.display = '';
	});
  
	//头工具栏事件
	table.on('toolbar(test)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'add':
	    		layer.open({
					  type: 1 		//Page层类型
					  ,area: ['500px', '400px'] //宽  高
					  ,title: '新增'
					  ,shade: 0.6 	//遮罩透明度
					  ,shadeClose: true //点击遮罩关闭
					  ,maxmin: true //允许全屏最小化
					  ,anim: 1 		//0-6的动画形式，-1不开启
					  ,content: $('#formDiv')
					  ,success: function () {
						  document.getElementById("addform").reset();
					  }
					  ,end: function () {
						  var formDiv = document.getElementById('formDiv');
						  formDiv.style.display = '';
					  }
					});
	      	break;
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
  
	//监听行工具事件
	table.on('tool(test)', function(obj){
		var data = obj.data;
		console.log(obj)
		
		if(obj.event === 'del'){
			if (obj.data.reserve1 != '-2') {
				toastr.warning("只能删除未审核的记录！");
				return false;
			}
		  layer.confirm('确定删除吗？', function(index){
		    var adID = obj.data.adID;
		    $.ajax({
		    	type:'post',
		    	url:'${pageContext.request.contextPath }/abnormalDisposal/deleteAbnormalDisposal.do',
		    	data:{"adID": adID},
		    	success:function(data){
		    		if(data>0){
		    			toastr.success("删除成功！");
		    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},2000);
		    		}else{
		    			toastr.warning("删除失败！");
		    		}
		    	}
		    		
		    })
		    layer.close(index);
		  });
		} else if(obj.event === 'edit'){
			if (obj.data.reserve1 != '-2') {
				toastr.warning("只能修改未审核的记录！");
				return false;
			}
			layer.open({
				  type: 1 		//Page层类型
				  ,area: ['30%', '70%'] //宽  高
				  ,title: '修改编辑'
				  ,shade: 0.6 	//遮罩透明度
				  ,maxmin: true //允许全屏最小化
				  ,anim: 1 		//0-6的动画形式，-1不开启
				  ,content: $('#formDiv')
				  ,success: function () {
					//回显表单数据
					for(var i=0;i<Object.entries(data).length;i++) {
						var id = '#' + Object.entries(data)[i][0];
						var text = Object.entries(data)[i][1];
						$(id).val(text);
					}
					$("#reserve5").val("edit");
					  form.render();
				  }	
				  ,end: function () {
				  	var formDiv = document.getElementById('formDiv');
				  	formDiv.style.display = '';
			  	  }
			});
		}else if(obj.event === 'approval'){
			if (obj.data.reserve1 == '0') {
				toastr.warning("请勿重复发起审批！");
				return false;
			}
			$.ajax({
				type:'post'
				,url:'${pageContext.request.contextPath }/abnormalDisposal/approvalAbnormalDisposal.do?adID='+obj.data.adID
				,success:function(res){
					if(res>0){
						toastr.success("发起成功！");
						setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},2000);
					}else{
						toastr.error("发起失败！");
					}
				}
			})
		}
	});
	/**
     * 表单校验
     */
    form.verify({
    	//value：表单的值、item：表单的DOM对象
    	adNum: function(value){
    		if(value == ''){
    			return '编号不能为空';
    		}
    	},
    	processPart: function(value){
    		if(value == ''){
    			return '发生工序段不能为空';
    		}
    	},
    	adDate: function(value){
    		if(value == ''){
    			return '时间不能为空';
    		}
    	},
    	squadLeader: function(value){
    		if(value == ''){
    			return '不能为空';
    		}
    	},
    	processer: function(value){
    		if(value == ''){
    			return '不能为空';
    		}
    	},
    	description: function(value){
    		if(value == ''){
    			return '异常说明不能为空';
    		}
    	}
    });
    /**
     * 通用表单提交(AJAX方式)（新增）
     */
    form.on('submit(addform)', function (data) {
    	$("#subBtn1").attr("disabled",true);
    	$.ajax({
			url : '${pageContext.request.contextPath }/abnormalDisposal/saveAbnormalDisposal.do',
			data : $('#addform').serialize(),
			type : "post",
			dataType : "json",
			}).done(
				function(res) {
					if (res > 0) {
						toastr.success('提交成功！');
						setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},2000);
					}
				}
			).fail(
				function(res) {
					layer.close(1);
					toastr.error('提交失败！');
				}
			)
			return false;
    });
});
function doPrint1() { 
	bdhtml = window.document.body.innerHTML; 
	sprnstr = "<!--startprint1-->"; 
	eprnstr = "<!--endprint1-->"; 
	prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 18); 
	prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); 
	//window.document.body.innerHTML =document.getElementById("mainbody").innerHTML; 
	//window.print(); 
	window.document.body.innerHTML = prnhtml; 
	window.print(); 
	window.document.body.innerHTML = bdhtml; 
}
function doPrint2() { 
	bdhtml = window.document.body.innerHTML; 
	sprnstr = "<!--startprint2-->"; 
	eprnstr = "<!--endprint2-->"; 
	prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 18); 
	prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); 
	//window.document.body.innerHTML =document.getElementById("mainbody").innerHTML; 
	//window.print(); 
	window.document.body.innerHTML = prnhtml; 
	window.print(); 
	window.document.body.innerHTML = bdhtml; 
}
function doPrint3() { 
	bdhtml = window.document.body.innerHTML; 
	sprnstr = "<!--startprint3-->"; 
	eprnstr = "<!--endprint3-->"; 
	prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 18); 
	prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); 
	//window.document.body.innerHTML =document.getElementById("mainbody").innerHTML; 
	//window.print(); 
	window.document.body.innerHTML = prnhtml; 
	window.print(); 
	window.document.body.innerHTML = bdhtml; 
}
function doPrint4() { 
	bdhtml = window.document.body.innerHTML; 
	sprnstr = "<!--startprint4-->"; 
	eprnstr = "<!--endprint4-->"; 
	prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 18); 
	prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); 
	//window.document.body.innerHTML =document.getElementById("mainbody").innerHTML; 
	//window.print(); 
	window.document.body.innerHTML = prnhtml; 
	window.print(); 
	window.document.body.innerHTML = bdhtml; 
}


toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
</script>

</body>
</html>